package aiP.A3.Image;

import javax.swing.*;

/**
 * Created with IntelliJ IDEA.
 * User: mizus
 * Date: 22.05.14
 * Time: 15:31
 * To change this template use File | Settings | File Templates.
 */
public class Imageloader {

    private static Imageloader imageloader;
    public static final int RED = 0;
    public static final int GREEN = 1;

    public static Imageloader getInstance(){
        if (imageloader == null) imageloader = new Imageloader();
        return imageloader;
    }

    public ImageIcon loadImage(int aId){
        switch (aId){
            case GREEN:
                  return createImageIcon("green.png", "");
            case RED:
                return createImageIcon("red.png", "");

        }
        throw new RuntimeException("Kein Bild gefunden, Pfad prüfen");
    }


    protected ImageIcon createImageIcon(String path,
                                        String description) {
        java.net.URL imgURL = getClass().getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL, description);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }
}
